package com.tydic.daily.utils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class SpringBeanUtil implements ApplicationContextAware {

	private static ApplicationContext applicationContext;

	public void setApplicationContext(ApplicationContext paramApplicationContext)
			throws BeansException {
		applicationContext = paramApplicationContext;
	}

	public static <T> T getBean(String beanName) {
		return (T) applicationContext.getBean(beanName);
	}

	public static String getMessage(String propertyKey) {
		return getMessage(propertyKey, null);
	}

	public static String getMessage(String propertyKey, Object[] args) {
		return applicationContext.getMessage(propertyKey, args, null);
	}
}
